<?php

class order extends bhCommon {



    /**
     * 订单详情
     */
    public function buy()
    {
        $id = intval($this->get('id'));
        $order = p_get('order', array('id' => $id, 'member_id' => $this->member['id']));
        if (empty($order)) {
            $this->json('订单不存在');
        }

        $goods = p_get('goods', array('id' => $order['goods_id']));
        $goods['cover_image'] = getImage($goods['cover_image']);

        $all_money = $order['price'] - $order['bargain'];
        $all_money = $all_money > 0 ? $all_money : 0;
        if ($goods['is_free'] == 2 && $goods['free'] > 0) {
            $all_money += $goods['free'];
        }

        $config = array(
            'special_reminder' => getConfig('special_reminder', '下单后6个工作日内发货, 新疆、西藏、内蒙古、港澳台地区暂不支持'),
        );

        $address = p_get('address', array('member_id' => $this->member['id']));

        $data = array(
            'order' => $order,
            'goods' => $goods,
            'all_money' => round($all_money, 2),
            'address' => $address,
            'config' => $config,
        );
        $this->json($data);
    }



}